package org.corespring.restaurant.service.impl;


import org.corespring.restaurant.model.Correo;
import org.corespring.restaurant.service.CorreoManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.MailException;
import org.springframework.mail.MailSender;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.stereotype.Component;

@Component
public class CorreoManagerImpl implements CorreoManager {

	@Autowired
	private SimpleMailMessage templateMessage;
	
	@Autowired
    private MailSender mailSender;
	
	public void sendMessage(Correo correo, String url) {

		//templateMessage.setBcc("ic.susan@gmail.com");
		templateMessage.setTo(correo.getNombresApellidos() + "<" +correo.getEmail() + ">");
		templateMessage.setSubject("Correo de contacto");
		templateMessage.setText(correo.getConsulta());
		
		try {			
			mailSender.send(templateMessage);
			
		} catch (MailException ex) {

			System.err.println(ex.getMessage());
		}		
    }

}
